#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

// 3085. 成为 K 特殊字符串需要删除的最少字符数
// https://leetcode.cn/problems/minimum-deletions-to-make-string-k-special/description/?envType=daily-question&envId=2025-06-21

class Solution
{
public:
    int minimumDeletions(string word, int k)
    {
        int ans = 0;
        vector<int> recordAlphaCnt(26);
        for (int i = 0; i < word.size(); i++)
        {
            recordAlphaCnt[word[i] - 'a']++;
        }
        sort(recordAlphaCnt.begin(), recordAlphaCnt.end());
        for (int i = 0; i < 26; i++)
        {
            int sum = 0;
            for (int j = i; j < 26; j++)
            {
                if (recordAlphaCnt[j] > recordAlphaCnt[i] + k)
                {
                    sum += min(recordAlphaCnt[j], recordAlphaCnt[i] + k);
                }
            }
            ans = max(ans, sum);
        }
        return word.size() - ans;
    }
};

int main()
{
    return 0;
}